// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2022-2023. All rights reserved.
 * Author: Huawei OS Kernel Lab
 * Create: Fri Sep 23 10:45:12 2022
 */

#include <linux/device.h>
#include <linux/export.h>
#include <linux/irq.h>
#include <linux/irqdesc.h>
#include <linux/irqhandler.h>
#include <linux/notifier.h>
#include <linux/pm.h>
#include <linux/pm_wakeup.h>
#include <linux/sched.h>
#include <linux/suspend.h>
#include <linux/syscore_ops.h>
#include <linux/types.h>

#include "power.h"

/* Corresponding to kernel/power/main.c */
struct workqueue_struct *pm_wq;
EXPORT_SYMBOL_GPL(pm_wq);

#ifdef CONFIG_PM_SLEEP
int pm_async_enabled;

int register_pm_notifier(struct notifier_block *nb) { return 0; }
EXPORT_SYMBOL_GPL(register_pm_notifier);

int unregister_pm_notifier(struct notifier_block *nb) { return 0; }
EXPORT_SYMBOL_GPL(unregister_pm_notifier);
#endif

/* Corresponding to kernel/power/suspend.c */
#ifdef CONFIG_SUSPEND
enum s2idle_states __read_mostly s2idle_state;
void s2idle_set_ops(const struct platform_s2idle_ops *ops) {}

unsigned int pm_suspend_global_flags;
EXPORT_SYMBOL_GPL(pm_suspend_global_flags);

int pm_suspend(suspend_state_t state) { return 0; }
EXPORT_SYMBOL(pm_suspend);

void s2idle_wake(void) { }
EXPORT_SYMBOL_GPL(s2idle_wake);

int suspend_valid_only_mem(suspend_state_t state) { return 0; }
EXPORT_SYMBOL_GPL(suspend_valid_only_mem);
#endif

/* Corresponding to kernel/power/process.c */
#ifdef CONFIG_FREEZER
unsigned int freeze_timeout_msecs;

int freeze_processes(void) { return 0; }
int freeze_kernel_threads(void) { return 0; }
void thaw_processes(void) { }
void thaw_kernel_threads(void) { }
#endif

/* Corresponding to kernel/freezer.c */
#ifdef CONFIG_FREEZER
bool pm_freezing;
bool pm_nosig_freezing;
bool freeze_task(struct task_struct *p) { return true; }
void __thaw_task(struct task_struct *t) { }

atomic_t system_freezing_cnt;
EXPORT_SYMBOL(system_freezing_cnt);

bool freezing_slow_path(struct task_struct *p) { return true; }
EXPORT_SYMBOL(freezing_slow_path);

bool __refrigerator(bool check_kthr_stop) { return true; }
EXPORT_SYMBOL(__refrigerator);

bool set_freezable(void) { return true; }
EXPORT_SYMBOL(set_freezable);
#endif

/* Corresponding to kernel/cgroup_freezer.c */
#if defined(CONFIG_FREEZER) && defined(CONFIG_CGROUP_FREEZER)
bool cgroup_freezing(struct task_struct *task) { return true; }
#endif

/* Corresponding to drivers/base/power/runtime.c */
void pm_runtime_init(struct device *dev) { }
void pm_runtime_remove(struct device *dev) { }
int pm_runtime_barrier(struct device *dev) { return 0; }
EXPORT_SYMBOL_GPL(pm_runtime_barrier);

int pm_runtime_force_suspend(struct device *dev) { return 0; }
EXPORT_SYMBOL_GPL(pm_runtime_force_suspend);

int pm_runtime_force_resume(struct device *dev) { return 0; }
EXPORT_SYMBOL_GPL(pm_runtime_force_resume);

int __pm_runtime_suspend(struct device *dev, int rpmflags) { return 0; }
EXPORT_SYMBOL_GPL(__pm_runtime_suspend);

int pm_schedule_suspend(struct device *dev, unsigned int delay)
{
	return 0;
}
EXPORT_SYMBOL_GPL(pm_schedule_suspend);

int __pm_runtime_set_status(struct device *dev, unsigned int status)
{
	return 0;
}
EXPORT_SYMBOL_GPL(__pm_runtime_set_status);

void pm_runtime_allow(struct device *dev) { }
EXPORT_SYMBOL_GPL(pm_runtime_allow);

void pm_runtime_forbid(struct device *dev) { }
EXPORT_SYMBOL_GPL(pm_runtime_forbid);

void pm_runtime_no_callbacks(struct device *dev) { }
EXPORT_SYMBOL_GPL(pm_runtime_no_callbacks);

void pm_runtime_irq_safe(struct device *dev) { }
EXPORT_SYMBOL_GPL(pm_runtime_irq_safe);

void __pm_runtime_use_autosuspend(struct device *dev, bool use) { }
EXPORT_SYMBOL_GPL(__pm_runtime_use_autosuspend);

void pm_runtime_set_autosuspend_delay(struct device *dev, int delay) { }
EXPORT_SYMBOL_GPL(pm_runtime_set_autosuspend_delay);

unsigned long pm_runtime_autosuspend_expiration(struct device *dev)
{
	return 0;
}
EXPORT_SYMBOL_GPL(pm_runtime_autosuspend_expiration);

void pm_runtime_set_memalloc_noio(struct device *dev, bool enable) { }
EXPORT_SYMBOL_GPL(pm_runtime_set_memalloc_noio);

void pm_runtime_enable(struct device *dev) { }
EXPORT_SYMBOL_GPL(pm_runtime_enable);

void __pm_runtime_disable(struct device *dev, bool check_resume) { }
EXPORT_SYMBOL_GPL(__pm_runtime_disable);

int __pm_runtime_idle(struct device *dev, int rpmflags) { return 0; }
EXPORT_SYMBOL_GPL(__pm_runtime_idle);

int __pm_runtime_resume(struct device *dev, int rpmflags) { return 0; }
EXPORT_SYMBOL_GPL(__pm_runtime_resume);

void pm_runtime_reinit(struct device *dev) { }
void pm_runtime_drop_link(struct device_link *link) { }
void pm_runtime_new_link(struct device *dev) { }
u64 pm_runtime_active_time(struct device *dev) { return 0; }
u64 pm_runtime_suspended_time(struct device *dev) { return 0; }
EXPORT_SYMBOL_GPL(pm_runtime_suspended_time);
void pm_runtime_get_suppliers(struct device *dev) { }
void pm_runtime_put_suppliers(struct device *dev) { }

/* Corresponding to drivers/base/power/wakeirq.c */
void dev_pm_arm_wake_irq(struct wake_irq *wirq) { }
void dev_pm_disarm_wake_irq(struct wake_irq *wirq) { }
void dev_pm_disable_wake_irq_check(struct device *dev, bool cond_disable) { }
void dev_pm_enable_wake_irq_check(struct device *dev, bool can_change_status) { }

int dev_pm_set_wake_irq(struct device *dev, int irq) { return 0; }
EXPORT_SYMBOL_GPL(dev_pm_set_wake_irq);

int dev_pm_set_dedicated_wake_irq(struct device *dev, int irq) { return 0; }
EXPORT_SYMBOL_GPL(dev_pm_set_dedicated_wake_irq);

void dev_pm_clear_wake_irq(struct device *dev) { }
EXPORT_SYMBOL_GPL(dev_pm_clear_wake_irq);

void dev_pm_enable_wake_irq(struct device *dev) { }
EXPORT_SYMBOL_GPL(dev_pm_enable_wake_irq);

void dev_pm_disable_wake_irq(struct device *dev) { }
EXPORT_SYMBOL_GPL(dev_pm_disable_wake_irq);

/* Corresponding to drivers/base/power/generic_ops.c */
int pm_generic_runtime_suspend(struct device *dev) { return 0; }
EXPORT_SYMBOL_GPL(pm_generic_runtime_suspend);

int pm_generic_runtime_resume(struct device *dev) { return 0; }
EXPORT_SYMBOL_GPL(pm_generic_runtime_resume);

#ifdef CONFIG_PM_SLEEP
int pm_generic_prepare(struct device *dev) { return 0; }
void pm_generic_complete(struct device *dev) { }

int pm_generic_suspend_late(struct device *dev) { return 0; }
EXPORT_SYMBOL_GPL(pm_generic_suspend_late);

int pm_generic_suspend_noirq(struct device *dev) { return 0; }
EXPORT_SYMBOL_GPL(pm_generic_suspend_noirq);

int pm_generic_suspend(struct device *dev) { return 0; }
EXPORT_SYMBOL_GPL(pm_generic_suspend);

int pm_generic_resume_early(struct device *dev) { return 0; }
EXPORT_SYMBOL_GPL(pm_generic_resume_early);

int pm_generic_resume_noirq(struct device *dev) { return 0; }
EXPORT_SYMBOL_GPL(pm_generic_resume_noirq);

int pm_generic_resume(struct device *dev) { return 0; }
EXPORT_SYMBOL_GPL(pm_generic_resume);

int pm_generic_freeze_noirq(struct device *dev) { return 0; }
EXPORT_SYMBOL_GPL(pm_generic_freeze_noirq);

int pm_generic_freeze_late(struct device *dev) { return 0; }
EXPORT_SYMBOL_GPL(pm_generic_freeze_late);

int pm_generic_freeze(struct device *dev) { return 0; }
EXPORT_SYMBOL_GPL(pm_generic_freeze);

int pm_generic_thaw_noirq(struct device *dev) { return 0; }
EXPORT_SYMBOL_GPL(pm_generic_thaw_noirq);

int pm_generic_thaw_early(struct device *dev) { return 0; }
EXPORT_SYMBOL_GPL(pm_generic_thaw_early);

int pm_generic_thaw(struct device *dev) { return 0; }
EXPORT_SYMBOL_GPL(pm_generic_thaw);

int pm_generic_restore_noirq(struct device *dev) { return 0; }
EXPORT_SYMBOL_GPL(pm_generic_restore_noirq);

int pm_generic_restore_early(struct device *dev) { return 0; }
EXPORT_SYMBOL_GPL(pm_generic_restore_early);

int pm_generic_restore(struct device *dev) { return 0; }
EXPORT_SYMBOL_GPL(pm_generic_restore);

int pm_generic_poweroff_noirq(struct device *dev) { return 0; }
EXPORT_SYMBOL_GPL(pm_generic_poweroff_noirq);

int pm_generic_poweroff_late(struct device *dev) { return 0; }
EXPORT_SYMBOL_GPL(pm_generic_poweroff_late);

int pm_generic_poweroff(struct device *dev) { return 0; }
EXPORT_SYMBOL_GPL(pm_generic_poweroff);

void pm_complete_with_resume_check(struct device *dev) { }
EXPORT_SYMBOL_GPL(pm_complete_with_resume_check);
#endif

/* Corresponding to drivers/base/power/clock_ops.c */
int pm_clk_runtime_suspend(struct device *dev) { return 0; }
int pm_clk_runtime_resume(struct device *dev) { return 0; }

/* Corresponding to drivers/base/power/common.c */
int dev_pm_domain_attach(struct device *dev, bool power_on) { return 0; }
EXPORT_SYMBOL_GPL(dev_pm_domain_attach);

void dev_pm_domain_detach(struct device *dev, bool power_off) { }
EXPORT_SYMBOL_GPL(dev_pm_domain_detach);

struct device *dev_pm_domain_attach_by_name(struct device *dev,
					    const char *name)
{
	return NULL;
}
EXPORT_SYMBOL_GPL(dev_pm_domain_attach_by_name);

struct device *dev_pm_domain_attach_by_id(struct device *dev,
					  unsigned int index)
{
	return NULL;
}
EXPORT_SYMBOL_GPL(dev_pm_domain_attach_by_id);
